package com.zy.commom.utils;

/**
 * Created by ZYDR on 2015/12/26.
 */
public class IpUtil {
    public static int ip2Int(String ipAdress){
        String[] temp=ipAdress.split("\\.");

        int value=0;
        for(int i=0;i<4;i++){
            value<<=8;
            value+=Integer.parseInt(temp[i]);
        }
        return value;
    }

    public static void main(String args[]){
        System.out.println(ip2Int("255.0.0.0"));
        System.out.println(Integer.toBinaryString(ip2Int("255.255.0.0")));
        System.out.println(Integer.toBinaryString(-256));
    }
}
